package com.example.demo.mapper;

import com.example.demo.pojo.User;
import com.example.demo.pojo.UserExample;
import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    long countByExample(UserExample example);

    int deleteByExample(UserExample example);

    int deleteByPrimaryKey(Integer u_id);

    int insert(User record);

    int insertSelective(User record);

    List<User> selectByExample(UserExample example);

    User selectByPrimaryKey(Integer u_id);

    int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);

    int updateByExample(@Param("record") User record, @Param("example") UserExample example);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);


    //注解实现条件查询示例
    @Select({"<script>" +
            "    SELECT u_id, u_loginName, u_passWord, u_trueName,r_id FROM user" +
            "<where>" +
            "    <if test='u_trueName != null' >" +  //当参数为空进行全表查询
            "        and u_trueName like concat('%',#{u_trueName},'%')" +
            "    </if>" +
            "</where>" +
            "</script>"})
    List<User> findInfoByName(User user);
}
